<?php $__env->startSection('css'); ?>
    <style>
        .thumb {
            max-height: 60px;
        }
    </style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">广告回收站</strong> /
                <small>Ads Trash</small>
            </div>
        </div>
<br/>
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <button type="button" class="am-btn am-btn-default" id="force_destroy_checked">
                            <span class="am-icon-trash-o"></span> 删除
                        </button>
                        <button type="button" class="am-btn am-btn-success" id="restore_checked">
                            <span class="am-icon-reply"></span> 还原
                        </button>
                    </div>
                </div>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-check"><input type="checkbox" id="checked"></th>
                            <th class="table-id">编号</th>
                            <th>缩略图</th>
                            <th class="table-title">标题</th>
                            <th class="table-category">所属栏目</th>
                            <th class="table-date am-hide-sm-only">发布日期 &nbsp;/ &nbsp;删除日期</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach($ads as $ad): ?>
                        <tr>
                            <td><input type="checkbox" value="<?php echo e($ad->id); ?>" class="checked_id" name="checked_id[]">
                            </td>

                            <td class="ad_id"><?php echo e($ad->id); ?></td>
                            <td class="ad_thumb"><img src="<?php echo e($ad->thumb); ?>" alt="" class="thumb">
                            </td>
                            <td><?php echo e($ad->title); ?></td>
                            <td><?php echo e($ad->category_id=='1'?'首页焦点图 大图轮播':'首页banner 3广告'); ?></td>
                            <td><?php echo e($ad->created_at); ?> / <?php echo e($ad->deleted_at); ?></td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="/ads/ad/<?php echo e($ad->id); ?>/restore">
                                            <span class="am-icon-reply"></span> 还原
                                        </a>
                                        <a class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" href="/ads/ad/<?php echo e($ad->id); ?>/delete_force" data-method="delete" data-token="<?php echo e(csrf_token()); ?>" data-confirm="确定删除吗？">
                                            <span class="am-icon-trash-o"></span> 删除
                                        </a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>


                        </tbody>
                    </table>

                    <div class="am-cf" style="float: right">

                        <?php echo $ads->appends(Request::all())->links(); ?>


                    </div>
                    <hr />
                    <p>共<?php echo e($ads->total()); ?>条记录</p>
                    <hr>
                </form>
            </div>
        </div>
    </div>
    <?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script type="text/javascript">
        $(function(){
            $('#checked').click(function(){
                $('.checked_id').prop('checked',this.checked);
            })

            //多选恢复 用ajax实现
            $('#restore_checked').click(function(){
                var length=$('.checked_id:checked').length;
                if (length == 0) {
                    alert("您必须至少选中一条!");
                    return false;
                }

                //关键是获得要恢复的数组
                var ids='';
                $(".checked_id:checked").each(function(){
                    ids+=$(this).val()+' ';
                })
                console.log(ids);

                $.ajax({
                    url:'/ads/ad/restore_checked',
                    type:'get',
                    data:{ids:ids},
                    success:function(data){
                        console.log(data);
                        location.href = location.href+'?'+Math.random();
                    }
                })
            })


            //回收站多选删除没做！
            $('#force_destroy_checked').click(function(){
                alert('回收站多选删除没做！')
            })
        })
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>